package at.fhj.itm11.forum.api;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.inject.Named;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import at.fhj.itm11.forum.service.RatingService;
import at.fhj.itm11.forum.service.dtos.RatingDTO;

@Stateless
@Remote(RatingService.class)
public class RatingServiceApi implements RatingService {

	private final Logger logger = LoggerFactory.getLogger(getClass());
	
	@Inject
	@Named("ratingServiceImpl")
	private RatingService service;
	
	@Override
	public void rate(RatingDTO r) {
		logger.info("rate called from public API");
		service.rate(r);
	}

	@Override
	public int[] getRatingStatistics(Long postId) {
		logger.info("getRatingStatistics called from public API with postId " + postId);
		return service.getRatingStatistics(postId);
	}

	@Override
	public RatingDTO findRatingByRaterAndPost(Long userId, Long postId) {
		logger.info("findRatingByRaterAndPost called from public API with postId " + postId
				+ "and userId " + userId);
		return service.findRatingByRaterAndPost(userId, postId);
	}

}
